import {createStore,applyMiddleware} from 'redux';
import reducer from './reducer';
import logger from 'redux-logger';
import thunk from 'redux-thunk';
import {persistStore,persistReducer} from 'redux-persist';
import storage from 'redux-persist/lib/storage';

// 生成持久化reducer
let persistedReducer = persistReducer( 
    { key:'redux' , storage }, 
    reducer ,
);
// 创建store
let store = createStore(persistedReducer,applyMiddleware(thunk,logger));

// 生成持久化的store
export let persistor = persistStore(store);

export default store;